package cn.nbt.busManage.model.vo;

import cn.nbt.busManage.model.dto.NewsDto;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Getter;

import java.io.Serializable;
import java.sql.Date;
import java.time.LocalDateTime;

@Getter
public class NewsVo implements Serializable {
    private final Integer id;
    private final String title;
    private final String author;
    private final String content;
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private final LocalDateTime createTime;
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private final LocalDateTime updateTime;

    public NewsVo(NewsDto newsDto){
        this.id = newsDto.getId();
        this.title = newsDto.getTitle();
        this.author = newsDto.getAuthor();
        this.content = newsDto.getContent();
        this.createTime =newsDto.getCreateTime();
        this.updateTime = newsDto.getUpdateTime();
    }

    @JsonCreator
    public NewsVo(@JsonProperty("id") Integer id, @JsonProperty("title") String title,@JsonProperty("author") String author,@JsonProperty("content") String content,@JsonProperty("createTime") LocalDateTime createTime,@JsonProperty("updateTime") LocalDateTime updateTime) {
        this.id = id;
        this.title = title;
        this.author = author;
        this.content = content;
        this.createTime = createTime;
        this.updateTime = updateTime;
    }
}
